<html>
<head>
	<script type="text/javascript">
		var aJaxURL	= "server-side/report/raw.action.php";		//server side folder url
		var tName	= "report";
		var done      = 0;
		var rID       = 0;
		var qv ='';
		var r=new Object();
		var total = [3];
												//table name
		$(document).ready(function () {

			GetDate("start");
			GetDate("end");
			LoadTable();


			$(".inpt").change(function(){
				done=0;
				total=[3]
				$("#tb2,#tb1").hide();

				LoadTable();
			})

		});

function LoadTable(){
	start	= $("#start").val();
	end		= $("#end").val();
	GetDataTable(tName+done, aJaxURL, "get_list&start="+start+"&end="+end+"&done="+done+"&id="+rID+"&qv="+qv, 4, '', 0, "", 2, "desc", total);

    $.getJSON(aJaxURL,"act=chart&start="+start+"&end="+end+"&done="+done+"&id="+rID+"&qv="+qv,function(result){
		$('#container_chart'+done).highcharts({
	        plotOptions: {
	            pie: {

	                dataLabels: {
	                    format: '<b>{point.name}</b>: {point.percentage:.1f} %',

	                }
	            }
	        },
			 xAxis:	 result.xAxis ,
			 series: result.series
		});

      });

    $("#report"+done+" tbody").off("click");
	$("#report"+done+" tbody").on("click", "tr", function () {
	  done = parseInt(($($($(this).parent()).parent()).attr( "id" )).substring(6, 7)) + 1;
	  $("#tb"+done).show();
	  console.log( done );
	  var nTds = $("td", this);
      rID = $(nTds[0]).text();
      qv = $(nTds[2]).text();
      if(done==1) total=[2,6]
      if(done==2) total=[2,4]
      LoadTable();
});
}

	 //   $("#" + tname + " tbody").off("click");


    </script>
</head>

<body>
    <div id="dt_example" class="ex_highlight_row">
        <div id="container" style="width: 90%">
            <div id="dynamic">
            	<h2 align="center">პასიური კლიენტები</h2>
				<div id="button_area">
	            		<input type="text" id="start" class="inpt " style="height: 20px;" />
	            		<input type="text" id="end" class="inpt " style="height: 20px;"/>

                </div>
				<br/>
	<table style="width: 100%">
	<tr><td>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
	<table class="display" id="report0">
                    <thead>
                        <tr id="datatable_header">
                            <th>ID</th>
                             <th style="width: 150px;">პროდუქტი</th>
                             <th style="width: 100px;">რაოდენობა</th>
                             <th style="width: 100px;">ღირებულება</th>

                        </tr>
                    </thead>
                   <tfoot class="center_price">
                        <tr>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                    </tr>
         </table>
        </td><td style="width: 70%">
         <div id="container_chart0"></div>
         </td> </tr>
    </table>
    <br />
    <hr />
    <br />
    <table id="tb1">
    <tr><td>
     <table class="display" id="report1">
                   <thead>
                        <tr id="datatable_header">
                            <th>ID</th>
                            <th style="width: 150px;">პროდუქტი</th>
                            <th style="width: 70px;">რაოდენობა</th>
                            <th style="width: 70px;">საშ. ფასი</th>
                            <th style="width: 70px;">მაქს. ფასი</th>
                            <th style="width: 70px;">მინ. ფასი</th>
                            <th style="width: 70px;">სულ. ფასი</th>
                            <th style="width: 70px;">%</th>
                        </tr>
                   </thead>
                   <tfoot class="center_price">
                        <tr>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                    </tr>
                    </tfoot>
      </table></td><td style="width: 50%">
       <div id="container_chart1"></div>
      </td></tr>
    </table>
    <br />
    <hr />
    <br />
     <table id="tb2">
    <tr><td >
     <table class="display" id="report2">
                   <thead>
                        <tr id="datatable_header">
                            <th>ID</th>
                            <th style="width: 150px;">პროდუქტი</th>
                            <th style="width: 100px;">რაოდენობა</th>
                            <th style="width: 100px;">ერთეულის ფასი</th>
                            <th style="width: 100px;">საერთო  ფასი</th>
                             <th style="width: 100px;">%</th>
                        </tr>
                   </thead>
                    <tfoot class="center_price">
                        <tr>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                    </tr>
                    </tfoot>
      </table></td><td style="width: 50%">
       <div id="container_chart2"></div>
      </td></tr>
    </table>

            </div>
        </div>
    </div>
</body>
</html>